C51 COMPILER V9.60.0.0   MAIN                                                              07/03/2023 14:57:11 PAGE 1   


C51 COMPILER V9.60.0.0, COMPILATION OF MODULE MAIN
OBJECT MODULE PLACED IN .\Release\main.obj
COMPILER INVOKED BY: C:\Keil_v5\C51\BIN\C51.EXE main.c OPTIMIZE(0,SPEED) REGFILE(.\Release\Sample_DrvSDM_MultiB.ORC) BRO
                    -WSE INCDIR(..\..\..\..\C51SIS\C51;..\..\..\Include\Driver) DEBUG OBJECTEXTEND TABS(2) OBJECT(.\Release\main.obj)

line level    source

   1          /**************************************************************************//**
   2           * @file           main.c
   3           * @version        V1.0
   4           * $Revision:      1 $
   5           * $Date:          2017/01/04 $
   6           * @brief          Main function
   7           * @Author         Jeffrey Kang
   8           * @ContactInfo    chkang@esmt.com.tw
   9           *
  10           * @note
  11           *
  12           * Copyright (C) 1998 Elite Semiconductor Memory Technology Corp.
  13           * All rights reserved.
  14           *
  15           ******************************************************************************/
  16          
  17          
  18          #include <REG52.h>
  19          #include "system_FE81001.h"
  20          
  21          
  22          static volatile unsigned char raw_data[3] = {0};
  23          
  24          
  25          
  26          /**
  27           * @brief       delay function
  28           *
  29           * @param       None
  30           *
  31           * @return      None
  32           *
  33           * @details     1. 
  34           */
  35          void delay (void)
  36          {
  37   1        unsigned int i;
  38   1        
  39   1        for( i = 0 ; i < 200 ; i++ ){}
  40   1      }
  41          
  42          
  43          /**
  44           * @brief       SDMISR function
  45           *
  46           * @param       None
  47           *
  48           * @return      None
  49           *
  50           * @details     1. 
  51           */
  52          const void SDMISR (void) interrupt ISR_SDM
  53          {
  54   1        unsigned char int_stat = SDM->intstat;             
C51 COMPILER V9.60.0.0   MAIN                                                              07/03/2023 14:57:11 PAGE 2   

  55   1        
  56   1        SDM->intstat = 0x81;   // clear interrupt flag
  57   1        
  58   1        /* fetch calibration data */
  59   1        raw_data[0] = SDM->rawdata[0];  // L_byte
  60   1        raw_data[1] = SDM->rawdata[1];  // M_byte
  61   1        raw_data[2] = SDM->rawdata[2];  // H_byte
  62   1        
  63   1        /* enable global interrupt */
  64   1        INTC->int_gmask = 0x01;
  65   1      }
  66          
  67          
  68          /**
  69           * @brief       SDMConfig function
  70           *
  71           * @param       None
  72           *
  73           * @return      None
  74           *
  75           * @details     1. 
  76           */
  77          void SDMConfig (void)
  78          {
  79   1          // RTD
  80   1        
  81   1          //Set OSR
  82   1          OSR_32768();
  83   1        
  84   1          //Set INMUX
  85   1          Set_input_channel_Ch6();
  86   1        
  87   1          //Set Rmux
  88   1          Set_Vref_1p2V();
  89   1          
  90   1          //Set INBUF
  91   1          Enable_Input_buffer();
  92   1          
  93   1          //Set VRBUF
  94   1          Enable_Vref_buffer();
  95   1        
  96   1          //Set Vref Gain
  97   1          Set_Vref_Gain_x1_div4();    // 1/4Vref  -> 1.2/4 = 0.3V
  98   1        
  99   1          //Set ADCGN
 100   1          Set_ADC_Gain_x1();
 101   1          
 102   1          //Enable TMPSNS
 103   1          Enable_TMPSNS();
 104   1          
 105   1          //Enable ADC
 106   1          Enable_ADC();
 107   1          
 108   1          //  Enable Interrupt
 109   1          Enable_SDM_inerrupt();
 110   1      
 111   1      }
 112          
 113          
 114          /**
 115           * @brief       ANACConfig function
 116           *
C51 COMPILER V9.60.0.0   MAIN                                                              07/03/2023 14:57:11 PAGE 3   

 117           * @param       None
 118           *
 119           * @return      None
 120           *
 121           * @details     1. 
 122           */
 123          void ANACConfig ()
 124          {
 125   1        //  Enalbe BIAS LDOA VCM
 126   1        Enable_BIAS();
 127   1        Enable_LDOA();
 128   1        Enable_VCM();
 129   1        
 130   1        //  Enable DAC1P
 131   1        Enable_DAC1P();
 132   1        
 133   1        //  Enable PSW
 134   1        Enable_PSW();
 135   1        
 136   1        //  Enable DAC1
 137   1        Enable_IDAC1();
 138   1        
 139   1        //  Set DAC1 Current 
 140   1        Set_IDAC1_Current(Current_1200uA);
 141   1        
 142   1      }
 143          
 144          /**
 145           * @brief       IOConfig function
 146           *
 147           * @param       None
 148           *
 149           * @return      None
 150           *
 151           * @details     1. 
 152           */
 153          void IOConfig()
 154          {
 155   1        /* Set PC7 input as button */
 156   1        PORT_SetPCInput(BIT7);
 157   1      
 158   1        /* Set PD1. ,PD2.,PD3 output */
 159   1        PORT_SetPDPushPull(BIT1 | BIT2 | BIT3 );
 160   1      
 161   1        /* LED Ini */
 162   1        PD1 = 0; // LED_G1 On
 163   1        PD2 = 1 ; //LED_R Off
 164   1        PD3= 0;  // LED_G2  On
 165   1      }
 166          
 167          
 168          /**
 169           * @brief       CLKConfig function
 170           *
 171           * @param       None
 172           *
 173           * @return      None
 174           *
 175           * @details     1. 
 176           */
 177          void CLKConfig()
 178          {
C51 COMPILER V9.60.0.0   MAIN                                                              07/03/2023 14:57:11 PAGE 4   

 179   1        /* enable GPIO clock */
 180   1        PORT_PAPBPCPD_Clock_Enable();
 181   1        
 182   1        /* enable SDM & ANA clock */
 183   1        En_SDM_clk();
 184   1        En_ANA_clk();
 185   1        
 186   1        /* sdm clock divider */
 187   1        Set_SDM_clk_250K();   
 188   1      }
 189          
 190          
 191          /**
 192           * @brief       main function
 193           *
 194           * @param       None
 195           *
 196           * @return      None
 197           *
 198           * @details     1. 
 199           */
 200          int main (void)
 201          {
 202   1        CLKConfig();
 203   1        IOConfig();
 204   1        
 205   1        ANACConfig();
 206   1        SDMConfig();
 207   1        
 208   1        /* enable global interrupt */
 209   1        INTC->int_gmask = 0x01;
 210   1        
 211   1        delay();
 212   1        
 213   1        while(1);
 214   1      }
 215          


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    483    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =      6    ----
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)
